package com.guoqiang.scanner;

import java.util.Scanner;

public class Demo05 {
    public static void main(String[] args) {
        double sum = 0; //和
        int count = 0; //计算输入多少个数字

        Scanner scanner = new Scanner(System.in);
        //通过循环判断是否还有输入，并在里面对每一个进行求和统计
        while (scanner.hasNextDouble()) {
            double x = scanner.nextDouble();
            count = count + 1;
            sum = sum + x;

            System.out.println("输入了第" +count+"个数据，然后当前的结果sum=" + sum);
        }
        System.out.println(count + "个数的和为" + count);
        System.out.println(count + "个数的平均值为" + (sum/count));

        scanner.close();
    }
}
